package com.real8.plusplayground.client.shell;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DeckLayoutPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.real8.plusplayground.client.menu.MenuView;

public class PlusPlaygroundShellViewImpl extends Composite implements
		PlusPlaygroundShellView {

	private static PlusToSocialShellViewImplUiBinder uiBinder = GWT
			.create(PlusToSocialShellViewImplUiBinder.class);

	interface PlusToSocialShellViewImplUiBinder extends
			UiBinder<Widget, PlusPlaygroundShellViewImpl> {
	}

	/**
	 * The container that holds the menu.
	 */
	@UiField
	SimplePanel menuContainer;

	/**
	 * The container that holds content.
	 */
	@UiField
	DeckLayoutPanel contentContainer;

	/**
	 * The widget displayed when the user has not selected something
	 */
	@UiField
	Widget contentEmptyMessage;

	@UiField
	HTMLPanel logPanel;

	public PlusPlaygroundShellViewImpl() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setWidget(IsWidget content) {
		contentContainer.setWidget((content == null) ? contentEmptyMessage
				: content);
	}

	@Override
	public void setMenu(MenuView menuView) {
		menuContainer.setWidget(menuView.asWidget());
	}

	@Override
	public void println(String value) {
		logPanel.add(new Label(value));
	}
}
